<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

use App\Libs\Liao\LiaoDb;
use App\Libs\Liao\LiaoFunction;

function liao_url_parse($url, $params)
{
    $params = (array)$params;
    foreach ($params as $key => $val) {
        if (!is_string ($val) && !is_numeric ($val)) {
            $val = 'null';
        }
        $val = (string)$val;
        $key = (string)$key;
        $url = str_replace ('{' . $key . '}', $val, $url);
    }
    $url = url ($url);

    return $url;
}
Route::get('/html/{dir}/{file}','HtmlController@index');
Route::get('/html/{dir}/{dir2}/{file}','HtmlController@index');
Route::get ('/', function () {
    $info         = [];
    $info['id']   = 1;
    $info['name'] = 'liao';
    $info['two']  = ['one' => 1, 'two' => 2];
    $info         = (object)$info;
    //dd($info);
    $url = liao_url_parse ('/ddd/{id}/{name}', $info);
    dd ($url);

    return view ('welcome');
});
Route::get ('ddd/{id}', function ($id) {
    var_dump ($id);
});
Route::get ('/', function () {
    echo Hash::make('123456');
    EXIT;

    $LiaoDb       = new LiaoDb();
    $LiaoFunction = new LiaoFunction();
    $ret          = $LiaoDb->getTables ();
    //$LiaoDb->table_name = 'tab_views';
    $ret = $LiaoDb->setTableName ('tab_views')->getColumn ();
    $ret = $LiaoFunction->getFieldToChinese ('id');
    dd ($ret);
});
//Route::controller('test','TestController');

Auth::routes ();

Route::get ('/home', 'HomeController@index')->name ('home');


Route::get ('/redirect', function () {
    $query = http_build_query ([
        'client_id'     => '4',
        'redirect_uri'  => 'http://localhost:63342',
        'response_type' => 'code',
        'scope'         => '',
        'secret'        => 'UBYqv43bkVXTUr64VJ6gTFKPKYdykmM6oyUqsiS4'
    ]);

    return redirect (url ('/oauth/authorize') . '?' . $query);
});
Route::post ('login', 'API\PassportController@login');
Route::post ('register', 'API\PassportController@register');

Route::group (['middleware' => 'auth:api'], function () {
    Route::post ('get-details', 'API\PassportController@getDetails');
});

Route::resource('liao_user', 'UserController');


Route::any('send_mail','SendMailController@index');